package com.bsoft.gol.hcb.dao.prescriptionCirculation;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import pcn.prescriptionCirculation.OdsOrderPrescriptionInfo;

import java.util.List;

/**
 * Created by ChenJij on 2021/8/30.
 */
public abstract class OdsOrderPrescriptionInfoDAO extends HibernateSupportDelegateDAO<OdsOrderPrescriptionInfo> {
    public OdsOrderPrescriptionInfoDAO() {
        this.setKeyField("orderPrescriptionInfoId");
    }

    @DAOMethod(sql = "select count(1) from OdsOrderPrescriptionInfo a,OdsPrescriptionOrder b  where a.orderId = b.orderId and  a.orgId =:orgId and a.prescriptionInfoId =:prescriptionInfoId and b.payStatus in ('0','1') and b.deleteFlag='0' ")
    public abstract long getPayedCount(@DAOParam("orgId")String orgId,@DAOParam("prescriptionInfoId")String prescriptionInfoId);


    @DAOMethod(sql = "from OdsOrderPrescriptionInfo where orderId =:orderId")
    public abstract List<OdsOrderPrescriptionInfo> findByOrderId(@DAOParam("orderId")String orderId);

    @DAOMethod(sql = "from OdsOrderPrescriptionInfo where orderId =:orderId and prescriptionInfoId=:prescriptionInfoId")
    public abstract OdsOrderPrescriptionInfo getByOrderIdAndPrescriptionInfoId(@DAOParam("orderId")String orderId,@DAOParam("prescriptionInfoId")String prescriptionInfoId);


    @DAOMethod(sql = "select count(1) from OdsOrderPrescriptionInfo a,OdsPrescriptionOrder b  where a.orderId = b.orderId and  a.orgId =:orgId and a.prescriptionInfoId in:prescriptionInfoIdList and b.payStatus in ('0','1') and b.deleteFlag='0' ")
    public abstract long getPayedCountByPrescriptionInfoIdList(@DAOParam("orgId")String orgId,@DAOParam("prescriptionInfoIdList")List<String> prescriptionInfoIdList);

}